/**
 * Copyright (c) 2017-2017 All Rights Reserved.
 */
package com.zbest.zpay.exchange.biz.action.pay;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zbest.zpay.masterdata.cache.ChannelConfigCache;
import com.zbest.zpay.masterdata.dal.model.ChannelConfigDO;
import com.zbest.zpay.masterdata.model.TransType;
import com.zbest.zpay.service.paycore.model.PayInfoDTO;
import com.zbest.zpay.service.paycore.model.PaySubInfoDTO;
import com.zbest.zpay.service.paycore.model.PaycoreKeyEnum;
import com.zbest.zpay.shared.process.BaseAction;
import com.zbest.zpay.shared.process.ProcessResult;

/**
 * 
 *
 * @author Administrator
 * @version $Id: ChannelRouteAction.java, v 0.1 2017-4-23 下午8:36:53 Administrator Exp $
 */
@Service("channelRouteAction")
public class ChannelRouteAction extends BaseAction {

    @Resource
    private ChannelConfigCache channelConfigCache;

    /** 
     * @see com.zbest.zpay.shared.process.BaseAction#perform(com.zbest.zpay.shared.process.ProcessResult)
     */
    @Override
    public void perform(ProcessResult processResponse) {

        PayInfoDTO payInfoDTO = getValue(PaycoreKeyEnum.PAY_INFO.getCode());
        List<PaySubInfoDTO> subInfoDTOList = payInfoDTO.getPaySubInfoDTOList();

        //对每个支付子单都进行路由找到支付渠道,目前比较简单
        for (PaySubInfoDTO paySubInfoDTO : subInfoDTOList) {
            ChannelConfigDO channelConfigDO = channelConfigCache.get(paySubInfoDTO.getInstId(),
                TransType.DEPOSIT.name());
            paySubInfoDTO.setChannelId(channelConfigDO.getChannelId());
        }
    }

}
